package com.ruoyi.ms.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ms.domain.MsPackage;
import com.ruoyi.ms.service.IMsPackageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 妙手订单信息Controller
 * 
 * @author chdx
 * @date 2022-12-04
 */
@Controller
@RequestMapping("/ms/MsPackage")
public class MsPackageController extends BaseController
{
    private String prefix = "ms/MsPackage";

    @Autowired
    private IMsPackageService msPackageService;

    @RequiresPermissions("ms:MsPackage:view")
    @GetMapping()
    public String MsPackage()
    {
        return prefix + "/MsPackage";
    }

    /**
     * 查询妙手订单信息列表
     */
    @RequiresPermissions("ms:MsPackage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsPackage msPackage)
    {
        startPage();
        List<MsPackage> list = msPackageService.selectMsPackageList(msPackage);
        return getDataTable(list);
    }

    /**
     * 导出妙手订单信息列表
     */
    @RequiresPermissions("ms:MsPackage:export")
    @Log(title = "妙手订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsPackage msPackage)
    {
        List<MsPackage> list = msPackageService.selectMsPackageList(msPackage);
        ExcelUtil<MsPackage> util = new ExcelUtil<MsPackage>(MsPackage.class);
        return util.exportExcel(list, "妙手订单信息数据");
    }

    /**
     * 新增妙手订单信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存妙手订单信息
     */
    @RequiresPermissions("ms:MsPackage:add")
    @Log(title = "妙手订单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsPackage msPackage)
    {
        return toAjax(msPackageService.insertMsPackage(msPackage));
    }

    /**
     * 修改妙手订单信息
     */
    @RequiresPermissions("ms:MsPackage:edit")
    @GetMapping("/edit/{msPackageId}")
    public String edit(@PathVariable("msPackageId") Long msPackageId, ModelMap mmap)
    {
        MsPackage msPackage = msPackageService.selectMsPackageByMsPackageId(msPackageId);
        mmap.put("msPackage", msPackage);
        return prefix + "/edit";
    }

    /**
     * 修改保存妙手订单信息
     */
    @RequiresPermissions("ms:MsPackage:edit")
    @Log(title = "妙手订单信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsPackage msPackage)
    {
        return toAjax(msPackageService.updateMsPackage(msPackage));
    }

    /**
     * 删除妙手订单信息
     */
    @RequiresPermissions("ms:MsPackage:remove")
    @Log(title = "妙手订单信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msPackageService.deleteMsPackageByMsPackageIds(ids));
    }
}
